package com.aepryus.loom;

import java.util.*;

public class Register<T extends Entry> implements Entry {
	private String name;
	private Map<String,T> library;

	public Register (String name) {
		this.name = name;
		library = new HashMap<String,T>();
	}

	public String getName () {return name;}
	public Set<String> keySet () {return library.keySet();}

	public void register (T entry) {
		library.put(entry.getName(),entry);
	}
	public T getEntry (String name) {
		T entry = library.get(name);
		if (entry == null) throw new RuntimeException("Entry ["+name+"] not registered in library ["+this.name+"]");
		return entry;
	}
}
